<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    var validMountainArray = function (A, l = 0, r = A.length - 1) {
      while (A[l] < A[l + 1]) l++
      while (A[r] < A[r - 1]) r--
      return l && l !== A.length - 1 && l === r
    };
    console.log(validMountainArray([2, 1]))
  </script>
</body>

</html>